<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>Reranker Framework (ReFr): factory.H Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">Reranker Framework (ReFr)
   
   </div>
   <div id="projectbrief">Reranking framework for structure prediction and discriminative language modeling</div>
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.6.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>File&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div class="header">
  <div class="headertitle">
<div class="title">factory.H</div>  </div>
</div><!--header-->
<div class="contents">
<a href="factory_8_h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">// Copyright 2012, Google Inc.</span>
<a name="l00002"></a>00002 <span class="comment">// All rights reserved.</span>
<a name="l00003"></a>00003 <span class="comment">//</span>
<a name="l00004"></a>00004 <span class="comment">// Redistribution and use in source and binary forms, with or without</span>
<a name="l00005"></a>00005 <span class="comment">// modification, are permitted provided that the following conditions are</span>
<a name="l00006"></a>00006 <span class="comment">// met:</span>
<a name="l00007"></a>00007 <span class="comment">//</span>
<a name="l00008"></a>00008 <span class="comment">//   * Redistributions of source code must retain the above copyright</span>
<a name="l00009"></a>00009 <span class="comment">//     notice, this list of conditions and the following disclaimer.</span>
<a name="l00010"></a>00010 <span class="comment">//   * Redistributions in binary form must reproduce the above</span>
<a name="l00011"></a>00011 <span class="comment">//     copyright notice, this list of conditions and the following disclaimer</span>
<a name="l00012"></a>00012 <span class="comment">//     in the documentation and/or other materials provided with the</span>
<a name="l00013"></a>00013 <span class="comment">//     distribution.</span>
<a name="l00014"></a>00014 <span class="comment">//   * Neither the name of Google Inc. nor the names of its</span>
<a name="l00015"></a>00015 <span class="comment">//     contributors may be used to endorse or promote products derived from</span>
<a name="l00016"></a>00016 <span class="comment">//     this software without specific prior written permission.</span>
<a name="l00017"></a>00017 <span class="comment">//</span>
<a name="l00018"></a>00018 <span class="comment">// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS</span>
<a name="l00019"></a>00019 <span class="comment">// &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT</span>
<a name="l00020"></a>00020 <span class="comment">// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR</span>
<a name="l00021"></a>00021 <span class="comment">// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT</span>
<a name="l00022"></a>00022 <span class="comment">// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,</span>
<a name="l00023"></a>00023 <span class="comment">// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT</span>
<a name="l00024"></a>00024 <span class="comment">// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,</span>
<a name="l00025"></a>00025 <span class="comment">// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY</span>
<a name="l00026"></a>00026 <span class="comment">// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT</span>
<a name="l00027"></a>00027 <span class="comment">// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE</span>
<a name="l00028"></a>00028 <span class="comment">// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</span>
<a name="l00029"></a>00029 <span class="comment">// -----------------------------------------------------------------------------</span>
<a name="l00030"></a>00030 <span class="comment">//</span>
<a name="l00031"></a>00031 <span class="comment">//</span>
<a name="l00035"></a>00035 <span class="comment"></span>
<a name="l00036"></a>00036 <span class="preprocessor">#ifndef RERANKER_FACTORY_H_</span>
<a name="l00037"></a>00037 <span class="preprocessor"></span><span class="preprocessor">#define RERANKER_FACTORY_H_</span>
<a name="l00038"></a>00038 <span class="preprocessor"></span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include &lt;sstream&gt;</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include &lt;memory&gt;</span>
<a name="l00042"></a>00042 <span class="preprocessor">#include &lt;unordered_map&gt;</span>
<a name="l00043"></a>00043 <span class="preprocessor">#include &lt;unordered_set&gt;</span>
<a name="l00044"></a>00044 <span class="preprocessor">#include &lt;vector&gt;</span>
<a name="l00045"></a>00045 <span class="preprocessor">#include &lt;stdexcept&gt;</span>
<a name="l00046"></a>00046 
<a name="l00047"></a>00047 <span class="preprocessor">#include &quot;<a class="code" href="stream-tokenizer_8_h.html" title="Provides the StreamTokenizer  class.">stream-tokenizer.H</a>&quot;</span>
<a name="l00048"></a>00048 <span class="preprocessor">#include &quot;<a class="code" href="environment_8_h.html" title="Provides an interface for an Environment, which contains a map from variables of a specific type (pri...">environment.H</a>&quot;</span>
<a name="l00049"></a>00049 
<a name="l00050"></a>00050 <span class="keyword">namespace </span>reranker {
<a name="l00051"></a>00051 
<a name="l00052"></a>00052 <span class="keyword">using</span> std::cerr;
<a name="l00053"></a>00053 <span class="keyword">using</span> std::endl;
<a name="l00054"></a>00054 <span class="keyword">using</span> std::ostream;
<a name="l00055"></a>00055 <span class="keyword">using</span> std::ostringstream;
<a name="l00056"></a>00056 <span class="keyword">using</span> std::shared_ptr;
<a name="l00057"></a>00057 <span class="keyword">using</span> std::unordered_map;
<a name="l00058"></a>00058 <span class="keyword">using</span> std::unordered_set;
<a name="l00059"></a>00059 <span class="keyword">using</span> std::vector;
<a name="l00060"></a>00060 
<a name="l00076"></a>00076 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00077"></a><a class="code" href="classreranker_1_1_type_name.html">00077</a> <span class="keyword">class </span><a class="code" href="classreranker_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName</a> {
<a name="l00078"></a>00078  <span class="keyword">public</span>:
<a name="l00079"></a><a class="code" href="classreranker_1_1_type_name.html#a5f7ad50c4280ca3b7dccafd01292a861">00079</a>   <span class="keywordtype">string</span> <a class="code" href="classreranker_1_1_type_name.html#a5f7ad50c4280ca3b7dccafd01292a861">ToString</a>() {
<a name="l00080"></a>00080     <span class="keywordflow">return</span> <a class="code" href="classreranker_1_1_factory.html" title="Factory for dynamically created instance of the specified type.">Factory&lt;T&gt;</a>().BaseName();
<a name="l00081"></a>00081   }
<a name="l00082"></a>00082 };
<a name="l00083"></a>00083 
<a name="l00086"></a>00086 <span class="keyword">template</span> &lt;&gt;
<a name="l00087"></a><a class="code" href="classreranker_1_1_type_name_3_01bool_01_4.html">00087</a> <span class="keyword">class </span><a class="code" href="classreranker_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName</a>&lt;bool&gt; {
<a name="l00088"></a>00088  <span class="keyword">public</span>:
<a name="l00089"></a><a class="code" href="classreranker_1_1_type_name_3_01bool_01_4.html#af46b41e8e17b8364fb7d509451de7971">00089</a>   <span class="keywordtype">string</span> <a class="code" href="classreranker_1_1_type_name_3_01bool_01_4.html#af46b41e8e17b8364fb7d509451de7971">ToString</a>() {
<a name="l00090"></a>00090     <span class="keywordflow">return</span> <span class="stringliteral">&quot;bool&quot;</span>;
<a name="l00091"></a>00091   }
<a name="l00092"></a>00092 };
<a name="l00093"></a>00093 
<a name="l00096"></a>00096 <span class="keyword">template</span> &lt;&gt;
<a name="l00097"></a><a class="code" href="classreranker_1_1_type_name_3_01int_01_4.html">00097</a> <span class="keyword">class </span><a class="code" href="classreranker_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName</a>&lt;int&gt; {
<a name="l00098"></a>00098  <span class="keyword">public</span>:
<a name="l00099"></a><a class="code" href="classreranker_1_1_type_name_3_01int_01_4.html#a43bf68a6438d411446c7b64dd1e64ca5">00099</a>   <span class="keywordtype">string</span> <a class="code" href="classreranker_1_1_type_name_3_01int_01_4.html#a43bf68a6438d411446c7b64dd1e64ca5">ToString</a>() {
<a name="l00100"></a>00100     <span class="keywordflow">return</span> <span class="stringliteral">&quot;int&quot;</span>;
<a name="l00101"></a>00101   }
<a name="l00102"></a>00102 };
<a name="l00103"></a>00103 
<a name="l00106"></a>00106 <span class="keyword">template</span> &lt;&gt;
<a name="l00107"></a><a class="code" href="classreranker_1_1_type_name_3_01double_01_4.html">00107</a> <span class="keyword">class </span><a class="code" href="classreranker_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName</a>&lt;double&gt; {
<a name="l00108"></a>00108  <span class="keyword">public</span>:
<a name="l00109"></a><a class="code" href="classreranker_1_1_type_name_3_01double_01_4.html#a68a6c91168cfc554848e1dd619a6267f">00109</a>   <span class="keywordtype">string</span> <a class="code" href="classreranker_1_1_type_name_3_01double_01_4.html#a68a6c91168cfc554848e1dd619a6267f">ToString</a>() {
<a name="l00110"></a>00110     <span class="keywordflow">return</span> <span class="stringliteral">&quot;double&quot;</span>;
<a name="l00111"></a>00111   }
<a name="l00112"></a>00112 };
<a name="l00113"></a>00113 
<a name="l00116"></a>00116 <span class="keyword">template</span> &lt;&gt;
<a name="l00117"></a><a class="code" href="classreranker_1_1_type_name_3_01string_01_4.html">00117</a> <span class="keyword">class </span><a class="code" href="classreranker_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName</a>&lt;string&gt; {
<a name="l00118"></a>00118  <span class="keyword">public</span>:
<a name="l00119"></a><a class="code" href="classreranker_1_1_type_name_3_01string_01_4.html#ac1e64d59aea0ebef6675b163b94b2e15">00119</a>   <span class="keywordtype">string</span> <a class="code" href="classreranker_1_1_type_name_3_01string_01_4.html#ac1e64d59aea0ebef6675b163b94b2e15">ToString</a>() {
<a name="l00120"></a>00120     <span class="keywordflow">return</span> <span class="stringliteral">&quot;string&quot;</span>;
<a name="l00121"></a>00121   }
<a name="l00122"></a>00122 };
<a name="l00123"></a>00123 
<a name="l00128"></a>00128 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00129"></a><a class="code" href="classreranker_1_1_type_name_3_01shared__ptr_3_01_t_01_4_01_4.html">00129</a> <span class="keyword">class </span><a class="code" href="classreranker_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName</a>&lt;shared_ptr&lt;T&gt; &gt; {
<a name="l00130"></a>00130  <span class="keyword">public</span>:
<a name="l00131"></a><a class="code" href="classreranker_1_1_type_name_3_01shared__ptr_3_01_t_01_4_01_4.html#ada3094e3f39bb0e3e5aa47e3b6696860">00131</a>   <span class="keywordtype">string</span> <a class="code" href="classreranker_1_1_type_name_3_01shared__ptr_3_01_t_01_4_01_4.html#ada3094e3f39bb0e3e5aa47e3b6696860">ToString</a>() {
<a name="l00132"></a>00132     <span class="keywordflow">return</span> <a class="code" href="classreranker_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName&lt;T&gt;</a>().<a class="code" href="classreranker_1_1_type_name.html#a5f7ad50c4280ca3b7dccafd01292a861">ToString</a>();
<a name="l00133"></a>00133   }
<a name="l00134"></a>00134 };
<a name="l00135"></a>00135 
<a name="l00143"></a>00143 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00144"></a><a class="code" href="classreranker_1_1_type_name_3_01vector_3_01_t_01_4_01_4.html">00144</a> <span class="keyword">class </span><a class="code" href="classreranker_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName</a>&lt;vector&lt;T&gt; &gt; {
<a name="l00145"></a>00145  <span class="keyword">public</span>:
<a name="l00146"></a><a class="code" href="classreranker_1_1_type_name_3_01vector_3_01_t_01_4_01_4.html#a8ec76a5aaa57f6c7f76d86011b64ccfa">00146</a>   <span class="keywordtype">string</span> <a class="code" href="classreranker_1_1_type_name_3_01vector_3_01_t_01_4_01_4.html#a8ec76a5aaa57f6c7f76d86011b64ccfa">ToString</a>() {
<a name="l00147"></a>00147     <span class="keywordflow">return</span> <a class="code" href="classreranker_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName&lt;T&gt;</a>().<a class="code" href="classreranker_1_1_type_name.html#a5f7ad50c4280ca3b7dccafd01292a861">ToString</a>() + <span class="stringliteral">&quot;[]&quot;</span>;
<a name="l00148"></a>00148   }
<a name="l00149"></a>00149 };
<a name="l00150"></a>00150 
<a name="l00155"></a><a class="code" href="classreranker_1_1_member_initializer.html">00155</a> <span class="keyword">class </span><a class="code" href="classreranker_1_1_member_initializer.html" title="An interface for initializers of members of a Factory-constructible object.">MemberInitializer</a> {
<a name="l00156"></a>00156  <span class="keyword">public</span>:
<a name="l00157"></a><a class="code" href="classreranker_1_1_member_initializer.html#a93e6c74c8cb94bee8968e56853517bfe">00157</a>   <a class="code" href="classreranker_1_1_member_initializer.html#a93e6c74c8cb94bee8968e56853517bfe">MemberInitializer</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;name, <span class="keywordtype">bool</span> required) :
<a name="l00158"></a>00158       <a class="code" href="classreranker_1_1_member_initializer.html#a4907fd4c837c5dfc19b602228e0edc92" title="The name of this member.">name_</a>(name), <a class="code" href="classreranker_1_1_member_initializer.html#a337ee2f5e378b5c4ddee7f649bf0f3c1" title="The number of times this member initializer&rsquo;s Init method has been invoked.">initialized_</a>(0), <a class="code" href="classreranker_1_1_member_initializer.html#aaeaa1401323e62caa4be09788f2af699" title="Whether this member is required to be initialized.">required_</a>(required) { }
<a name="l00159"></a><a class="code" href="classreranker_1_1_member_initializer.html#a7658426295dd45e3c38979b8d696e220">00159</a>   <span class="keyword">virtual</span> <a class="code" href="classreranker_1_1_member_initializer.html#a7658426295dd45e3c38979b8d696e220">~MemberInitializer</a>() { }
<a name="l00160"></a><a class="code" href="classreranker_1_1_member_initializer.html#abe8bbe05d631bbe1976b4de8a853eed3">00160</a>   <span class="keyword">virtual</span> <span class="keywordtype">string</span> <a class="code" href="classreranker_1_1_member_initializer.html#abe8bbe05d631bbe1976b4de8a853eed3">Name</a>() { <span class="keywordflow">return</span> <a class="code" href="classreranker_1_1_member_initializer.html#a4907fd4c837c5dfc19b602228e0edc92" title="The name of this member.">name_</a>; }
<a name="l00161"></a>00161   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_member_initializer.html#a085d766d1e86d17d4323a46933fc012b">Init</a>(<a class="code" href="classreranker_1_1_stream_tokenizer.html" title="A simple class for tokenizing a stream of tokens for the formally specified language used to construc...">StreamTokenizer</a> &amp;st, <a class="code" href="classreranker_1_1_environment.html" title="An interface for an environment in which variables of various types are mapped to their values...">Environment</a> *env) = 0;
<a name="l00164"></a><a class="code" href="classreranker_1_1_member_initializer.html#aae102105102356914b4a92d7d92b0a56">00164</a>   <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classreranker_1_1_member_initializer.html#aae102105102356914b4a92d7d92b0a56" title="Returns the number of times this member initializer&rsquo;s Init method has been invoked.">Initialized</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classreranker_1_1_member_initializer.html#a337ee2f5e378b5c4ddee7f649bf0f3c1" title="The number of times this member initializer&rsquo;s Init method has been invoked.">initialized_</a>; }
<a name="l00165"></a><a class="code" href="classreranker_1_1_member_initializer.html#a628dcf5f10c9fb79f27254fcfd21cfe3">00165</a>   <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classreranker_1_1_member_initializer.html#a628dcf5f10c9fb79f27254fcfd21cfe3">Required</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="classreranker_1_1_member_initializer.html#aaeaa1401323e62caa4be09788f2af699" title="Whether this member is required to be initialized.">required_</a>; }
<a name="l00166"></a>00166  <span class="keyword">protected</span>:
<a name="l00168"></a><a class="code" href="classreranker_1_1_member_initializer.html#a4907fd4c837c5dfc19b602228e0edc92">00168</a>   <span class="keywordtype">string</span> <a class="code" href="classreranker_1_1_member_initializer.html#a4907fd4c837c5dfc19b602228e0edc92" title="The name of this member.">name_</a>;
<a name="l00171"></a><a class="code" href="classreranker_1_1_member_initializer.html#a337ee2f5e378b5c4ddee7f649bf0f3c1">00171</a>   <span class="keywordtype">int</span> <a class="code" href="classreranker_1_1_member_initializer.html#a337ee2f5e378b5c4ddee7f649bf0f3c1" title="The number of times this member initializer&rsquo;s Init method has been invoked.">initialized_</a>;
<a name="l00173"></a><a class="code" href="classreranker_1_1_member_initializer.html#aaeaa1401323e62caa4be09788f2af699">00173</a>   <span class="keywordtype">bool</span> <a class="code" href="classreranker_1_1_member_initializer.html#aaeaa1401323e62caa4be09788f2af699" title="Whether this member is required to be initialized.">required_</a>;
<a name="l00174"></a>00174 };
<a name="l00175"></a>00175 
<a name="l00176"></a>00176 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00177"></a><a class="code" href="classreranker_1_1_typed_member_initializer.html">00177</a> <span class="keyword">class </span><a class="code" href="classreranker_1_1_typed_member_initializer.html">TypedMemberInitializer</a> : <span class="keyword">public</span> <a class="code" href="classreranker_1_1_member_initializer.html" title="An interface for initializers of members of a Factory-constructible object.">MemberInitializer</a> {
<a name="l00178"></a>00178  <span class="keyword">public</span>:
<a name="l00179"></a><a class="code" href="classreranker_1_1_typed_member_initializer.html#a95c3abb535f08c9ec87a5539d1f7f1c1">00179</a>   <a class="code" href="classreranker_1_1_typed_member_initializer.html#a95c3abb535f08c9ec87a5539d1f7f1c1">TypedMemberInitializer</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;name, T *member, <span class="keywordtype">bool</span> required = <span class="keyword">false</span>) :
<a name="l00180"></a>00180       <a class="code" href="classreranker_1_1_member_initializer.html" title="An interface for initializers of members of a Factory-constructible object.">MemberInitializer</a>(name, required), <a class="code" href="classreranker_1_1_typed_member_initializer.html#a35a862355f7f07417f88fa9ac67315aa">member_</a>(member) { }
<a name="l00181"></a><a class="code" href="classreranker_1_1_typed_member_initializer.html#ae4bfd91cc07047abb3eab4681f068743">00181</a>   <span class="keyword">virtual</span> <a class="code" href="classreranker_1_1_typed_member_initializer.html#ae4bfd91cc07047abb3eab4681f068743">~TypedMemberInitializer</a>() { }
<a name="l00182"></a><a class="code" href="classreranker_1_1_typed_member_initializer.html#afca07d3366246c6c1a4c98a0df499b30">00182</a>   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_typed_member_initializer.html#afca07d3366246c6c1a4c98a0df499b30">Init</a>(<a class="code" href="classreranker_1_1_stream_tokenizer.html" title="A simple class for tokenizing a stream of tokens for the formally specified language used to construc...">StreamTokenizer</a> &amp;st, <a class="code" href="classreranker_1_1_environment.html" title="An interface for an environment in which variables of various types are mapped to their values...">Environment</a> *env) {
<a name="l00183"></a>00183     env-&gt;<a class="code" href="classreranker_1_1_environment.html#a95b0818fd8c3311b224ab177defda94f" title="Sets the specified variable to the value obtained from the following tokens available from the specif...">ReadAndSet</a>(<a class="code" href="classreranker_1_1_member_initializer.html#abe8bbe05d631bbe1976b4de8a853eed3">Name</a>(), st, <a class="code" href="classreranker_1_1_type_name.html" title="We use the templated class TypeName to be able to take an actual C++ type and get the type name strin...">TypeName&lt;T&gt;</a>().ToString());
<a name="l00184"></a>00184     <a class="code" href="classreranker_1_1_var_map_base.html" title="A base class for a mapping from variables of a specific type to their values.">VarMapBase</a> *var_map = env-&gt;<a class="code" href="classreranker_1_1_environment.html#a64763b2d3e5a5f1cc7a69ecc018d6003" title="Retrieves the VarMap instance for the specified variable.">GetVarMap</a>(<a class="code" href="classreranker_1_1_member_initializer.html#abe8bbe05d631bbe1976b4de8a853eed3">Name</a>());
<a name="l00185"></a>00185     <a class="code" href="classreranker_1_1_var_map.html" title="A container to hold the mapping between named variables of a specific type and their values...">VarMap&lt;T&gt;</a> *typed_var_map = <span class="keyword">dynamic_cast&lt;</span><a class="code" href="classreranker_1_1_var_map.html" title="A container to hold the mapping between named variables of a specific type and their values...">VarMap&lt;T&gt;</a> *<span class="keyword">&gt;</span>(var_map);
<a name="l00186"></a>00186     <span class="keywordflow">if</span> (typed_var_map != NULL) {
<a name="l00187"></a>00187       <span class="keywordtype">bool</span> success = typed_var_map-&gt;<a class="code" href="classreranker_1_1_var_map.html#a06ae9d1793c6e507b975ac23f9d7af58" title="Assigns the value of the specified variable to the object pointed to by the value parameter...">Get</a>(<a class="code" href="classreranker_1_1_member_initializer.html#abe8bbe05d631bbe1976b4de8a853eed3">Name</a>(), <a class="code" href="classreranker_1_1_typed_member_initializer.html#a35a862355f7f07417f88fa9ac67315aa">member_</a>);
<a name="l00188"></a>00188       <span class="keywordflow">if</span> (success) {
<a name="l00189"></a>00189         ++(<a class="code" href="classreranker_1_1_member_initializer.html#a337ee2f5e378b5c4ddee7f649bf0f3c1" title="The number of times this member initializer&rsquo;s Init method has been invoked.">initialized_</a>);
<a name="l00190"></a>00190       }
<a name="l00191"></a>00191     }
<a name="l00192"></a>00192   }
<a name="l00193"></a>00193  <span class="keyword">protected</span>:
<a name="l00194"></a><a class="code" href="classreranker_1_1_typed_member_initializer.html#a35a862355f7f07417f88fa9ac67315aa">00194</a>   T *<a class="code" href="classreranker_1_1_typed_member_initializer.html#a35a862355f7f07417f88fa9ac67315aa">member_</a>;
<a name="l00195"></a>00195 };
<a name="l00196"></a>00196 
<a name="l00203"></a><a class="code" href="classreranker_1_1_initializers.html">00203</a> <span class="keyword">class </span><a class="code" href="classreranker_1_1_initializers.html" title="A container for all the member initializers for a particular Factory-constructible instance...">Initializers</a> {
<a name="l00204"></a>00204  <span class="keyword">public</span>:
<a name="l00207"></a>00207   <span class="keyword">typedef</span> unordered_map&lt;string, MemberInitializer *&gt;::const_iterator
<a name="l00208"></a><a class="code" href="classreranker_1_1_initializers.html#a81b3d2bebb775df4c0b83366c833f035">00208</a>       <a class="code" href="classreranker_1_1_initializers.html#a81b3d2bebb775df4c0b83366c833f035" title="Forward the const_iterator typedef of the internal data structure, to make code compact and readable...">const_iterator</a>;
<a name="l00211"></a><a class="code" href="classreranker_1_1_initializers.html#aab6c04959dce47c42a3b8e9644526a05">00211</a>   <span class="keyword">typedef</span> unordered_map&lt;string, MemberInitializer *&gt;::iterator <a class="code" href="classreranker_1_1_initializers.html#aab6c04959dce47c42a3b8e9644526a05" title="Forward the iterator typedef of the internal data structure, to make code compact and readable...">iterator</a>;
<a name="l00212"></a>00212 
<a name="l00214"></a><a class="code" href="classreranker_1_1_initializers.html#ad48cd95efd3ba7d191c54837ea74ed60">00214</a>   <a class="code" href="classreranker_1_1_initializers.html#ad48cd95efd3ba7d191c54837ea74ed60" title="Constructs a new instance.">Initializers</a>() { }
<a name="l00216"></a><a class="code" href="classreranker_1_1_initializers.html#a4c2aba14b19b2b078a19a3749da6ceb1">00216</a>   <span class="keyword">virtual</span> <a class="code" href="classreranker_1_1_initializers.html#a4c2aba14b19b2b078a19a3749da6ceb1" title="Destroys this instance.">~Initializers</a>() {
<a name="l00217"></a>00217     <span class="keywordflow">for</span> (<a class="code" href="classreranker_1_1_initializers.html#aab6c04959dce47c42a3b8e9644526a05" title="Forward the iterator typedef of the internal data structure, to make code compact and readable...">iterator</a> init_it = initializers_.begin();
<a name="l00218"></a>00218          init_it != initializers_.end();
<a name="l00219"></a>00219          ++init_it) {
<a name="l00220"></a>00220       <span class="keyword">delete</span> init_it-&gt;second;
<a name="l00221"></a>00221     }
<a name="l00222"></a>00222   }
<a name="l00223"></a>00223 
<a name="l00224"></a>00224   <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;
<a name="l00225"></a><a class="code" href="classreranker_1_1_initializers.html#a9554990729db9c5d1b85925fc3c42d91">00225</a>   <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_initializers.html#a9554990729db9c5d1b85925fc3c42d91">Add</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;name, T *member, <span class="keywordtype">bool</span> required = <span class="keyword">false</span>) {
<a name="l00226"></a>00226     initializers_[name] = <span class="keyword">new</span> <a class="code" href="classreranker_1_1_typed_member_initializer.html">TypedMemberInitializer&lt;T&gt;</a>(name, member, required);
<a name="l00227"></a>00227   }
<a name="l00228"></a>00228 
<a name="l00232"></a><a class="code" href="classreranker_1_1_initializers.html#a3783e6f2fa0bc7330b6103eac1c86c58">00232</a>   <a class="code" href="classreranker_1_1_initializers.html#a81b3d2bebb775df4c0b83366c833f035" title="Forward the const_iterator typedef of the internal data structure, to make code compact and readable...">const_iterator</a> <a class="code" href="classreranker_1_1_initializers.html#a3783e6f2fa0bc7330b6103eac1c86c58" title="Returns a const iterator pointing to the beginning of the map from member names to pointers to TypedM...">begin</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> initializers_.begin(); }
<a name="l00237"></a><a class="code" href="classreranker_1_1_initializers.html#ad94d0fbca0b8da45e638439d9fa95bfb">00237</a>   <a class="code" href="classreranker_1_1_initializers.html#a81b3d2bebb775df4c0b83366c833f035" title="Forward the const_iterator typedef of the internal data structure, to make code compact and readable...">const_iterator</a> <a class="code" href="classreranker_1_1_initializers.html#ad94d0fbca0b8da45e638439d9fa95bfb" title="Returns a const iterator pointing to the end of the map from member names to pointers to TypedMemberI...">end</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> initializers_.end(); }
<a name="l00238"></a>00238 
<a name="l00243"></a><a class="code" href="classreranker_1_1_initializers.html#a96c3cd1dc3c275530613d0c8faada55b">00243</a>   <a class="code" href="classreranker_1_1_initializers.html#aab6c04959dce47c42a3b8e9644526a05" title="Forward the iterator typedef of the internal data structure, to make code compact and readable...">iterator</a> <a class="code" href="classreranker_1_1_initializers.html#a96c3cd1dc3c275530613d0c8faada55b" title="Returns an iterator pointing to the beginning of the map from member names to pointers to TypedMember...">begin</a>() { <span class="keywordflow">return</span> initializers_.begin(); }
<a name="l00247"></a><a class="code" href="classreranker_1_1_initializers.html#aec7eb1e8bf142ccf0023450e809a45d5">00247</a>   <a class="code" href="classreranker_1_1_initializers.html#aab6c04959dce47c42a3b8e9644526a05" title="Forward the iterator typedef of the internal data structure, to make code compact and readable...">iterator</a> <a class="code" href="classreranker_1_1_initializers.html#aec7eb1e8bf142ccf0023450e809a45d5" title="Returns an iterator pointing to the end of the map from member names to pointers to TypedMemberInitia...">end</a>() { <span class="keywordflow">return</span> initializers_.end(); }
<a name="l00248"></a>00248 
<a name="l00254"></a><a class="code" href="classreranker_1_1_initializers.html#ad789c774006d6d16b896c08e76de40e1">00254</a>   <a class="code" href="classreranker_1_1_initializers.html#a81b3d2bebb775df4c0b83366c833f035" title="Forward the const_iterator typedef of the internal data structure, to make code compact and readable...">const_iterator</a> <a class="code" href="classreranker_1_1_initializers.html#ad789c774006d6d16b896c08e76de40e1" title="Returns a const_iterator pointing to the MemberInitializer associated with the specified name...">find</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;name)<span class="keyword"> const </span>{
<a name="l00255"></a>00255     <span class="keywordflow">return</span> initializers_.find(name);
<a name="l00256"></a>00256   }
<a name="l00262"></a><a class="code" href="classreranker_1_1_initializers.html#a5eb65fc3a910912b9bb7eb9cfef09185">00262</a>   <a class="code" href="classreranker_1_1_initializers.html#aab6c04959dce47c42a3b8e9644526a05" title="Forward the iterator typedef of the internal data structure, to make code compact and readable...">iterator</a> <a class="code" href="classreranker_1_1_initializers.html#a5eb65fc3a910912b9bb7eb9cfef09185" title="Returns an iterator pointing to the MemberInitializer associated with the specified name...">find</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;name) {
<a name="l00263"></a>00263     <span class="keywordflow">return</span> initializers_.find(name);
<a name="l00264"></a>00264   }
<a name="l00265"></a>00265  <span class="keyword">private</span>:
<a name="l00266"></a>00266   unordered_map&lt;string, MemberInitializer *&gt; initializers_;
<a name="l00267"></a>00267 };
<a name="l00268"></a>00268 
<a name="l00271"></a><a class="code" href="classreranker_1_1_factory_base.html">00271</a> <span class="keyword">class </span><a class="code" href="classreranker_1_1_factory_base.html" title="An interface for all Factory instances, specifying a few pure virtual methods.">FactoryBase</a> {
<a name="l00272"></a>00272  <span class="keyword">public</span>:
<a name="l00273"></a><a class="code" href="classreranker_1_1_factory_base.html#a8e86a480405b484ac1b47c0487396cf8">00273</a>   <span class="keyword">virtual</span> <a class="code" href="classreranker_1_1_factory_base.html#a8e86a480405b484ac1b47c0487396cf8">~FactoryBase</a>() { }
<a name="l00279"></a>00279   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_factory_base.html#a2b7ed0a748bf9eefbc30355167fe8ad9" title="Clears the (possibly static) data of this factory.">Clear</a>() = 0;
<a name="l00281"></a>00281   <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">string</span> <a class="code" href="classreranker_1_1_factory_base.html#a3f0dd88a8da419dde3cbe3e97fda55ab" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() <span class="keyword">const</span> = 0;
<a name="l00288"></a>00288   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_factory_base.html#ada8c5df4396bb4e785b690d0a6d5922f" title="Collects the names of types registered with this factory.">CollectRegistered</a>(unordered_set&lt;string&gt; &amp;registered) <span class="keyword">const</span> = 0;
<a name="l00289"></a>00289 
<a name="l00290"></a>00290   <span class="keyword">virtual</span> <a class="code" href="classreranker_1_1_var_map_base.html" title="A base class for a mapping from variables of a specific type to their values.">VarMapBase</a> *<a class="code" href="classreranker_1_1_factory_base.html#a165b07587cacb1112b783f5191c51fd5">CreateVarMap</a>(<a class="code" href="classreranker_1_1_environment.html" title="An interface for an environment in which variables of various types are mapped to their values...">Environment</a> *env) <span class="keyword">const</span> = 0;
<a name="l00291"></a>00291 
<a name="l00292"></a>00292   <span class="keyword">virtual</span> <a class="code" href="classreranker_1_1_var_map_base.html" title="A base class for a mapping from variables of a specific type to their values.">VarMapBase</a> *<a class="code" href="classreranker_1_1_factory_base.html#a8ba4ece87f76449fbdc2702bb6ddcb76">CreateVectorVarMap</a>(<a class="code" href="classreranker_1_1_environment.html" title="An interface for an environment in which variables of various types are mapped to their values...">Environment</a> *env) <span class="keyword">const</span> = 0;
<a name="l00293"></a>00293 };
<a name="l00294"></a>00294 
<a name="l00296"></a><a class="code" href="classreranker_1_1_factory_container.html">00296</a> <span class="keyword">class </span><a class="code" href="classreranker_1_1_factory_container.html" title="A class to hold all Factory instances that have been created.">FactoryContainer</a> {
<a name="l00297"></a>00297  <span class="keyword">public</span>:
<a name="l00298"></a><a class="code" href="classreranker_1_1_factory_container.html#a5bf60c03af9c6d6266a8065b9e45b1d1">00298</a>   <span class="keyword">typedef</span> vector&lt;FactoryBase *&gt;::iterator <a class="code" href="classreranker_1_1_factory_container.html#a5bf60c03af9c6d6266a8065b9e45b1d1">iterator</a>;
<a name="l00299"></a>00299 
<a name="l00303"></a><a class="code" href="classreranker_1_1_factory_container.html#acc7effa13e093d95c7866d95ecda9324">00303</a>   <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_factory_container.html#acc7effa13e093d95c7866d95ecda9324" title="Adds the specified factory to this container of factories.">Add</a>(<a class="code" href="classreranker_1_1_factory_base.html" title="An interface for all Factory instances, specifying a few pure virtual methods.">FactoryBase</a> *factory) {
<a name="l00304"></a>00304     <span class="keywordflow">if</span> (!initialized_) {
<a name="l00305"></a>00305       factories_ = <span class="keyword">new</span> vector&lt;FactoryBase *&gt;();
<a name="l00306"></a>00306       initialized_ = 1;
<a name="l00307"></a>00307     }
<a name="l00308"></a>00308     factories_-&gt;push_back(factory);
<a name="l00309"></a>00309   }
<a name="l00311"></a><a class="code" href="classreranker_1_1_factory_container.html#ab242b39f86f6bccfae572108ef46f8e9">00311</a>   <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_factory_container.html#ab242b39f86f6bccfae572108ef46f8e9" title="Clears this container of factories.">Clear</a>() {
<a name="l00312"></a>00312     <span class="keywordflow">if</span> (initialized_) {
<a name="l00313"></a>00313       <span class="keywordflow">for</span> (vector&lt;FactoryBase *&gt;::iterator it = factories_-&gt;begin();
<a name="l00314"></a>00314            it != factories_-&gt;end();
<a name="l00315"></a>00315            ++it) {
<a name="l00316"></a>00316         (*it)-&gt;Clear();
<a name="l00317"></a>00317         <span class="keyword">delete</span> *it;
<a name="l00318"></a>00318       }
<a name="l00319"></a>00319       <span class="keyword">delete</span> factories_;
<a name="l00320"></a>00320     }
<a name="l00321"></a>00321   }
<a name="l00322"></a>00322 
<a name="l00323"></a>00323   <span class="comment">// Provide two methods to iterate over the FactoryBase instances</span>
<a name="l00324"></a>00324   <span class="comment">// held by this FactoryContainer.</span>
<a name="l00325"></a><a class="code" href="classreranker_1_1_factory_container.html#a8a206cc8e159df1be3c3b9ac3f87f8a3">00325</a>   <span class="keyword">static</span> <a class="code" href="classreranker_1_1_factory_container.html#a5bf60c03af9c6d6266a8065b9e45b1d1">iterator</a> <a class="code" href="classreranker_1_1_factory_container.html#a8a206cc8e159df1be3c3b9ac3f87f8a3">begin</a>() {
<a name="l00326"></a>00326     <span class="keywordflow">if</span> (factories_ == NULL) {
<a name="l00327"></a>00327       cerr &lt;&lt; <span class="stringliteral">&quot;FactoryContainer::begin: error: no FactoryBase instances!&quot;</span>
<a name="l00328"></a>00328            &lt;&lt; endl;
<a name="l00329"></a>00329     }
<a name="l00330"></a>00330     <span class="keywordflow">return</span> factories_-&gt;begin();
<a name="l00331"></a>00331   }
<a name="l00332"></a><a class="code" href="classreranker_1_1_factory_container.html#a34ca18c43c96d8f15f943ad3c86fd2b3">00332</a>   <span class="keyword">static</span> <a class="code" href="classreranker_1_1_factory_container.html#a5bf60c03af9c6d6266a8065b9e45b1d1">iterator</a> <a class="code" href="classreranker_1_1_factory_container.html#a34ca18c43c96d8f15f943ad3c86fd2b3">end</a>() {
<a name="l00333"></a>00333     <span class="keywordflow">if</span> (factories_ == NULL) {
<a name="l00334"></a>00334       cerr &lt;&lt; <span class="stringliteral">&quot;FactoryContainer::begin: error: no FactoryBase instances!&quot;</span>
<a name="l00335"></a>00335            &lt;&lt; endl;
<a name="l00336"></a>00336     }
<a name="l00337"></a>00337     <span class="keywordflow">return</span> factories_-&gt;end();
<a name="l00338"></a>00338   }
<a name="l00339"></a>00339 
<a name="l00343"></a><a class="code" href="classreranker_1_1_factory_container.html#a4ecabc625093e83cb762a27f8d175d88">00343</a>   <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_factory_container.html#a4ecabc625093e83cb762a27f8d175d88" title="Prints the base typenames for all factories along with a list of all concrete subtypes those factorie...">Print</a>(ostream &amp;os) {
<a name="l00344"></a>00344     <span class="keywordflow">if</span> (!initialized_) {
<a name="l00345"></a>00345       <span class="keywordflow">return</span>;
<a name="l00346"></a>00346     }
<a name="l00347"></a>00347     cerr &lt;&lt; <span class="stringliteral">&quot;Number of factories: &quot;</span> &lt;&lt; factories_-&gt;size() &lt;&lt; <span class="stringliteral">&quot;.&quot;</span> &lt;&lt; endl;
<a name="l00348"></a>00348     <span class="keywordflow">for</span> (vector&lt;FactoryBase *&gt;::iterator factory_it = factories_-&gt;begin();
<a name="l00349"></a>00349          factory_it != factories_-&gt;end();
<a name="l00350"></a>00350          ++factory_it) {
<a name="l00351"></a>00351       unordered_set&lt;string&gt; registered;
<a name="l00352"></a>00352       (*factory_it)-&gt;CollectRegistered(registered);
<a name="l00353"></a>00353       os &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; (*factory_it)-&gt;BaseName() &lt;&lt; <span class="stringliteral">&quot;&gt; can construct:\n&quot;</span>;
<a name="l00354"></a>00354       <span class="keywordflow">for</span> (unordered_set&lt;string&gt;::const_iterator it = registered.begin();
<a name="l00355"></a>00355            it != registered.end();
<a name="l00356"></a>00356            ++it) {
<a name="l00357"></a>00357         os &lt;&lt; <span class="stringliteral">&quot;\t&quot;</span> &lt;&lt; *it &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;
<a name="l00358"></a>00358       }
<a name="l00359"></a>00359     }
<a name="l00360"></a>00360     os.flush();
<a name="l00361"></a>00361   }
<a name="l00362"></a>00362  <span class="keyword">private</span>:
<a name="l00363"></a>00363   <span class="keyword">static</span> <span class="keywordtype">int</span> initialized_;
<a name="l00364"></a>00364   <span class="keyword">static</span> vector&lt;FactoryBase *&gt; *factories_;
<a name="l00365"></a>00365 };
<a name="l00366"></a>00366 
<a name="l00372"></a>00372 <span class="comment">// \tparam T the abstract type that this &lt;tt&gt;Constructor&lt;/tt&gt; constructs</span>
<a name="l00373"></a>00373 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00374"></a><a class="code" href="classreranker_1_1_constructor.html">00374</a> <span class="keyword">class </span><a class="code" href="classreranker_1_1_constructor.html" title="An interface with a single virtual method that constructs a concrete instance of the abstract type T...">Constructor</a> {
<a name="l00375"></a>00375  <span class="keyword">public</span>:
<a name="l00376"></a><a class="code" href="classreranker_1_1_constructor.html#a43269e3672a0638bb397800ab96acc33">00376</a>   <span class="keyword">virtual</span> <a class="code" href="classreranker_1_1_constructor.html#a43269e3672a0638bb397800ab96acc33">~Constructor</a>() { }
<a name="l00377"></a>00377   <span class="keyword">virtual</span> T *<a class="code" href="classreranker_1_1_constructor.html#a7cd26a61b1ace2b0e7cf677c8f60ab39">NewInstance</a>() <span class="keyword">const</span> = 0;
<a name="l00378"></a>00378 };
<a name="l00379"></a>00379 
<a name="l00382"></a><a class="code" href="classreranker_1_1_factory_constructible.html">00382</a> <span class="keyword">class </span><a class="code" href="classreranker_1_1_factory_constructible.html" title="An interface to make it easier to implement Factory-constructible types by implementing both required...">FactoryConstructible</a> {
<a name="l00383"></a>00383  <span class="keyword">public</span>:
<a name="l00384"></a><a class="code" href="classreranker_1_1_factory_constructible.html#a2624e3cbe74b266a004d70c28920ce34">00384</a>   <span class="keyword">virtual</span> <a class="code" href="classreranker_1_1_factory_constructible.html#a2624e3cbe74b266a004d70c28920ce34">~FactoryConstructible</a>() { }
<a name="l00385"></a><a class="code" href="classreranker_1_1_factory_constructible.html#a4a45cf0a7822b3cd26ec882f0330b788">00385</a>   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_factory_constructible.html#a4a45cf0a7822b3cd26ec882f0330b788">RegisterInitializers</a>(<a class="code" href="classreranker_1_1_initializers.html" title="A container for all the member initializers for a particular Factory-constructible instance...">Initializers</a> &amp;initializers) { }
<a name="l00386"></a><a class="code" href="classreranker_1_1_factory_constructible.html#a5a323858b80346e85b3282ddba53d4ad">00386</a>   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_factory_constructible.html#a5a323858b80346e85b3282ddba53d4ad">Init</a>(<span class="keyword">const</span> <a class="code" href="classreranker_1_1_environment.html" title="An interface for an environment in which variables of various types are mapped to their values...">Environment</a> *env, <span class="keyword">const</span> <span class="keywordtype">string</span> &amp;arg) { }
<a name="l00387"></a>00387 };
<a name="l00388"></a>00388 
<a name="l00395"></a>00395 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;
<a name="l00396"></a><a class="code" href="classreranker_1_1_factory.html">00396</a> <span class="keyword">class </span><a class="code" href="classreranker_1_1_factory.html" title="Factory for dynamically created instance of the specified type.">Factory</a> : <span class="keyword">public</span> <a class="code" href="classreranker_1_1_factory_base.html" title="An interface for all Factory instances, specifying a few pure virtual methods.">FactoryBase</a> {
<a name="l00397"></a>00397  <span class="keyword">public</span>:
<a name="l00399"></a><a class="code" href="classreranker_1_1_factory.html#ad22223cf69fd67cff3bfc6dec46ddbdd">00399</a>   <a class="code" href="classreranker_1_1_factory.html#ad22223cf69fd67cff3bfc6dec46ddbdd" title="Constructs a new factory.">Factory</a>() { }
<a name="l00400"></a>00400 
<a name="l00406"></a><a class="code" href="classreranker_1_1_factory.html#a555f8107c0c4866c5a00f9c8d3073ef2">00406</a>   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_factory.html#a555f8107c0c4866c5a00f9c8d3073ef2" title="Clears this factory of all (possibly static) data.">Clear</a>() {
<a name="l00407"></a>00407     <a class="code" href="classreranker_1_1_factory.html#a892eeb8c39013c68c4082c2247d1cbf3" title="Clears all static data associated with this class.">ClearStatic</a>();
<a name="l00408"></a>00408   }
<a name="l00409"></a>00409 
<a name="l00562"></a><a class="code" href="classreranker_1_1_factory.html#a68117013334b03c94fc525e62080311f">00562</a>   shared_ptr&lt;T&gt; <a class="code" href="classreranker_1_1_factory.html#a68117013334b03c94fc525e62080311f" title="Dynamically creates an object, whose type and initialization are contained in a specification string...">CreateOrDie</a>(<a class="code" href="classreranker_1_1_stream_tokenizer.html" title="A simple class for tokenizing a stream of tokens for the formally specified language used to construc...">StreamTokenizer</a> &amp;st, <a class="code" href="classreranker_1_1_environment.html" title="An interface for an environment in which variables of various types are mapped to their values...">Environment</a> *env = NULL) {
<a name="l00563"></a>00563     shared_ptr&lt;Environment&gt; env_ptr(env == NULL ?
<a name="l00564"></a>00564                                     <a class="code" href="classreranker_1_1_environment.html#a1214411c110887639ada037668265792" title="A static factory method to create a new, empty Environment instance.">Environment::CreateEmpty</a>() : env-&gt;<a class="code" href="classreranker_1_1_environment.html#ad5ad2fe5a00eba18331de208dd4f4b02" title="Returns a copy of this environment.">Copy</a>());
<a name="l00565"></a>00565     <span class="keywordtype">size_t</span> start = st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a2f79a9d009fac16c76c9bcf653fb88cc" title="Returns the next token&rsquo;s start position, or the byte position of the underlying byte stream if there ...">PeekTokenStart</a>();
<a name="l00566"></a>00566     <a class="code" href="classreranker_1_1_stream_tokenizer.html#a43c556f438853bde82330f852de412da" title="The set of types of tokens read by this stream tokenizer.">StreamTokenizer::TokenType</a> token_type = st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a69295644dad07656c4790d6d5ed87557" title="Returns the type of the next token, or EOF_TYPE if there is no next token.">PeekTokenType</a>();
<a name="l00567"></a>00567     <span class="keywordflow">if</span> (token_type == <a class="code" href="classreranker_1_1_stream_tokenizer.html#a43c556f438853bde82330f852de412daa900de35c73023cf15ec3954852da6809">StreamTokenizer::RESERVED_WORD</a> &amp;&amp;
<a name="l00568"></a>00568         (st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a7f53bc3134419cb7b7f00bbd39430b42" title="Returns the next token that would be returned by the Next method.">Peek</a>() == <span class="stringliteral">&quot;nullptr&quot;</span> || st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a7f53bc3134419cb7b7f00bbd39430b42" title="Returns the next token that would be returned by the Next method.">Peek</a>() == <span class="stringliteral">&quot;NULL&quot;</span>)) {
<a name="l00569"></a>00569       <span class="keywordflow">return</span> shared_ptr&lt;T&gt;();
<a name="l00570"></a>00570     }
<a name="l00571"></a>00571     <span class="keywordflow">if</span> (token_type != <a class="code" href="classreranker_1_1_stream_tokenizer.html#a43c556f438853bde82330f852de412daa6f3f909fb7f4fdc76c355f131a0cd392">StreamTokenizer::IDENTIFIER</a>) {
<a name="l00572"></a>00572       ostringstream err_ss;
<a name="l00573"></a>00573       err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classreranker_1_1_factory.html#a497687eed621332ca0b9883acc60ce82" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00574"></a>00574              &lt;&lt; <span class="stringliteral">&quot;error: expected type specifier token but found &quot;</span>
<a name="l00575"></a>00575              &lt;&lt; <a class="code" href="classreranker_1_1_stream_tokenizer.html#ad9765fd0018581aa96914ac773cbe450" title="Returns a string type name for the specified TokenType constant.">StreamTokenizer::TypeName</a>(token_type);
<a name="l00576"></a>00576       <span class="keywordflow">throw</span> std::runtime_error(err_ss.str());
<a name="l00577"></a>00577     }
<a name="l00578"></a>00578 
<a name="l00579"></a>00579     <span class="comment">// Read the concrete type of object to be created.</span>
<a name="l00580"></a>00580     <span class="keywordtype">string</span> type = st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a8fad418b62ae370295fe324229e5d43e" title="Returns the next token in the token stream.">Next</a>();
<a name="l00581"></a>00581 
<a name="l00582"></a>00582     <span class="comment">// Read the open parenthesis token.</span>
<a name="l00583"></a>00583     <span class="keywordflow">if</span> (st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a7f53bc3134419cb7b7f00bbd39430b42" title="Returns the next token that would be returned by the Next method.">Peek</a>() != <span class="stringliteral">&quot;(&quot;</span>) {
<a name="l00584"></a>00584       ostringstream err_ss;
<a name="l00585"></a>00585       err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classreranker_1_1_factory.html#a497687eed621332ca0b9883acc60ce82" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00586"></a>00586              &lt;&lt; <span class="stringliteral">&quot;error: expected &#39;(&#39; at stream position &quot;</span>
<a name="l00587"></a>00587              &lt;&lt; st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a2f79a9d009fac16c76c9bcf653fb88cc" title="Returns the next token&rsquo;s start position, or the byte position of the underlying byte stream if there ...">PeekTokenStart</a>() &lt;&lt; <span class="stringliteral">&quot; but found \&quot;&quot;</span> &lt;&lt; st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a7f53bc3134419cb7b7f00bbd39430b42" title="Returns the next token that would be returned by the Next method.">Peek</a>() &lt;&lt; <span class="stringliteral">&quot;\&quot;&quot;</span>;
<a name="l00588"></a>00588       <span class="keywordflow">throw</span> std::runtime_error(err_ss.str());
<a name="l00589"></a>00589     }
<a name="l00590"></a>00590     st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a8fad418b62ae370295fe324229e5d43e" title="Returns the next token in the token stream.">Next</a>();
<a name="l00591"></a>00591 
<a name="l00592"></a>00592     <span class="comment">// Attempt to create an instance of type.</span>
<a name="l00593"></a>00593     <span class="keyword">typename</span> unordered_map&lt;string, const Constructor&lt;T&gt; *&gt;::iterator cons_it =
<a name="l00594"></a>00594         cons_table_-&gt;find(type);
<a name="l00595"></a>00595     <span class="keywordflow">if</span> (cons_it == cons_table_-&gt;end()) {
<a name="l00596"></a>00596       ostringstream err_ss;
<a name="l00597"></a>00597       err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classreranker_1_1_factory.html#a497687eed621332ca0b9883acc60ce82" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00598"></a>00598              &lt;&lt; <span class="stringliteral">&quot;error: unknown type: \&quot;&quot;</span> &lt;&lt; type &lt;&lt; <span class="stringliteral">&quot;\&quot;&quot;</span>;
<a name="l00599"></a>00599       <span class="keywordflow">throw</span> std::runtime_error(err_ss.str());
<a name="l00600"></a>00600     }
<a name="l00601"></a>00601     shared_ptr&lt;T&gt; instance(cons_it-&gt;second-&gt;NewInstance());
<a name="l00602"></a>00602 
<a name="l00603"></a>00603     <span class="comment">// Ask new instance to set up member initializers.</span>
<a name="l00604"></a>00604     <a class="code" href="classreranker_1_1_initializers.html" title="A container for all the member initializers for a particular Factory-constructible instance...">Initializers</a> initializers;
<a name="l00605"></a>00605     instance-&gt;RegisterInitializers(initializers);
<a name="l00606"></a>00606 
<a name="l00607"></a>00607     <span class="comment">// Parse initializer list.</span>
<a name="l00608"></a>00608     <span class="keywordflow">while</span> (st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a7f53bc3134419cb7b7f00bbd39430b42" title="Returns the next token that would be returned by the Next method.">Peek</a>() != <span class="stringliteral">&quot;)&quot;</span>) {
<a name="l00609"></a>00609       token_type = st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a69295644dad07656c4790d6d5ed87557" title="Returns the type of the next token, or EOF_TYPE if there is no next token.">PeekTokenType</a>();
<a name="l00610"></a>00610       <span class="keywordflow">if</span> (token_type != <a class="code" href="classreranker_1_1_stream_tokenizer.html#a43c556f438853bde82330f852de412daa6f3f909fb7f4fdc76c355f131a0cd392">StreamTokenizer::IDENTIFIER</a>) {
<a name="l00611"></a>00611         ostringstream err_ss;
<a name="l00612"></a>00612         err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classreranker_1_1_factory.html#a497687eed621332ca0b9883acc60ce82" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00613"></a>00613                &lt;&lt; <span class="stringliteral">&quot;error: expected token of type IDENTIFIER at &quot;</span>
<a name="l00614"></a>00614                &lt;&lt; <span class="stringliteral">&quot;stream position &quot;</span> &lt;&lt; st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a2f79a9d009fac16c76c9bcf653fb88cc" title="Returns the next token&rsquo;s start position, or the byte position of the underlying byte stream if there ...">PeekTokenStart</a>() &lt;&lt; <span class="stringliteral">&quot; but found &quot;</span>
<a name="l00615"></a>00615                &lt;&lt; <a class="code" href="classreranker_1_1_stream_tokenizer.html#ad9765fd0018581aa96914ac773cbe450" title="Returns a string type name for the specified TokenType constant.">StreamTokenizer::TypeName</a>(token_type) &lt;&lt; <span class="stringliteral">&quot;: \&quot;&quot;</span>
<a name="l00616"></a>00616                &lt;&lt; st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a7f53bc3134419cb7b7f00bbd39430b42" title="Returns the next token that would be returned by the Next method.">Peek</a>() &lt;&lt; <span class="stringliteral">&quot;\&quot;&quot;</span>;
<a name="l00617"></a>00617         <span class="keywordflow">throw</span> std::runtime_error(err_ss.str());
<a name="l00618"></a>00618       }
<a name="l00619"></a>00619       <span class="keywordtype">size_t</span> member_name_start = st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a2f79a9d009fac16c76c9bcf653fb88cc" title="Returns the next token&rsquo;s start position, or the byte position of the underlying byte stream if there ...">PeekTokenStart</a>();
<a name="l00620"></a>00620       <span class="keywordtype">string</span> member_name = st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a8fad418b62ae370295fe324229e5d43e" title="Returns the next token in the token stream.">Next</a>();
<a name="l00621"></a>00621       <span class="keyword">typename</span> <a class="code" href="classreranker_1_1_initializers.html#aab6c04959dce47c42a3b8e9644526a05" title="Forward the iterator typedef of the internal data structure, to make code compact and readable...">Initializers::iterator</a> init_it = initializers.find(member_name);
<a name="l00622"></a>00622       <span class="keywordflow">if</span> (init_it == initializers.end()) {
<a name="l00623"></a>00623         ostringstream err_ss;
<a name="l00624"></a>00624         err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classreranker_1_1_factory.html#a497687eed621332ca0b9883acc60ce82" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00625"></a>00625                &lt;&lt; <span class="stringliteral">&quot;error: unknown member name \&quot;&quot;</span> &lt;&lt; member_name
<a name="l00626"></a>00626                &lt;&lt; <span class="stringliteral">&quot;\&quot; in initializer list for type &quot;</span> &lt;&lt; type &lt;&lt; <span class="stringliteral">&quot; at stream &quot;</span>
<a name="l00627"></a>00627                &lt;&lt; <span class="stringliteral">&quot;position &quot;</span> &lt;&lt; member_name_start;
<a name="l00628"></a>00628         <span class="keywordflow">throw</span> std::runtime_error(err_ss.str());
<a name="l00629"></a>00629       }
<a name="l00630"></a>00630       <a class="code" href="classreranker_1_1_member_initializer.html" title="An interface for initializers of members of a Factory-constructible object.">MemberInitializer</a> *member_initializer = init_it-&gt;second;
<a name="l00631"></a>00631 
<a name="l00632"></a>00632       <span class="comment">// Read open parenthesis.</span>
<a name="l00633"></a>00633       <span class="keywordflow">if</span> (st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a7f53bc3134419cb7b7f00bbd39430b42" title="Returns the next token that would be returned by the Next method.">Peek</a>() != <span class="stringliteral">&quot;(&quot;</span>) {
<a name="l00634"></a>00634         ostringstream err_ss;
<a name="l00635"></a>00635         err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classreranker_1_1_factory.html#a497687eed621332ca0b9883acc60ce82" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00636"></a>00636                &lt;&lt; <span class="stringliteral">&quot;error: expected &#39;(&#39; at stream position &quot;</span>
<a name="l00637"></a>00637                &lt;&lt; st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a2f79a9d009fac16c76c9bcf653fb88cc" title="Returns the next token&rsquo;s start position, or the byte position of the underlying byte stream if there ...">PeekTokenStart</a>() &lt;&lt; <span class="stringliteral">&quot; but found \&quot;&quot;</span> &lt;&lt; st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a7f53bc3134419cb7b7f00bbd39430b42" title="Returns the next token that would be returned by the Next method.">Peek</a>() &lt;&lt; <span class="stringliteral">&quot;\&quot;&quot;</span>;
<a name="l00638"></a>00638         <span class="keywordflow">throw</span> std::runtime_error(err_ss.str());
<a name="l00639"></a>00639       }
<a name="l00640"></a>00640       st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a8fad418b62ae370295fe324229e5d43e" title="Returns the next token in the token stream.">Next</a>();
<a name="l00641"></a>00641 
<a name="l00642"></a>00642       <span class="comment">// Initialize member based on following token(s).</span>
<a name="l00643"></a>00643       member_initializer-&gt;<a class="code" href="classreranker_1_1_member_initializer.html#a085d766d1e86d17d4323a46933fc012b">Init</a>(st, env_ptr.get());
<a name="l00644"></a>00644 
<a name="l00645"></a>00645       <span class="comment">// Read close parenthesis for current member initializer.</span>
<a name="l00646"></a>00646       <span class="keywordflow">if</span> (st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a7f53bc3134419cb7b7f00bbd39430b42" title="Returns the next token that would be returned by the Next method.">Peek</a>() != <span class="stringliteral">&quot;)&quot;</span>) {
<a name="l00647"></a>00647         ostringstream err_ss;
<a name="l00648"></a>00648         err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classreranker_1_1_factory.html#a497687eed621332ca0b9883acc60ce82" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00649"></a>00649                &lt;&lt; <span class="stringliteral">&quot;error: expected &#39;)&#39; at stream position &quot;</span>
<a name="l00650"></a>00650                &lt;&lt; st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a2f79a9d009fac16c76c9bcf653fb88cc" title="Returns the next token&rsquo;s start position, or the byte position of the underlying byte stream if there ...">PeekTokenStart</a>() &lt;&lt; <span class="stringliteral">&quot; but found \&quot;&quot;</span> &lt;&lt; st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a7f53bc3134419cb7b7f00bbd39430b42" title="Returns the next token that would be returned by the Next method.">Peek</a>() &lt;&lt; <span class="stringliteral">&quot;\&quot;&quot;</span>;
<a name="l00651"></a>00651         <span class="keywordflow">throw</span> std::runtime_error(err_ss.str());
<a name="l00652"></a>00652       }
<a name="l00653"></a>00653       st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a8fad418b62ae370295fe324229e5d43e" title="Returns the next token in the token stream.">Next</a>();
<a name="l00654"></a>00654 
<a name="l00655"></a>00655       <span class="comment">// Each member initializer must be followed by a comma or the final</span>
<a name="l00656"></a>00656       <span class="comment">// closing parenthesis.</span>
<a name="l00657"></a>00657       <span class="keywordflow">if</span> (st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a7f53bc3134419cb7b7f00bbd39430b42" title="Returns the next token that would be returned by the Next method.">Peek</a>() != <span class="stringliteral">&quot;,&quot;</span>  &amp;&amp; st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a7f53bc3134419cb7b7f00bbd39430b42" title="Returns the next token that would be returned by the Next method.">Peek</a>() != <span class="stringliteral">&quot;)&quot;</span>) {
<a name="l00658"></a>00658         ostringstream err_ss;
<a name="l00659"></a>00659         err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classreranker_1_1_factory.html#a497687eed621332ca0b9883acc60ce82" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00660"></a>00660                &lt;&lt; <span class="stringliteral">&quot;error: expected &#39;,&#39; or &#39;)&#39; at stream position &quot;</span>
<a name="l00661"></a>00661                &lt;&lt; st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a2f79a9d009fac16c76c9bcf653fb88cc" title="Returns the next token&rsquo;s start position, or the byte position of the underlying byte stream if there ...">PeekTokenStart</a>() &lt;&lt; <span class="stringliteral">&quot; but found \&quot;&quot;</span> &lt;&lt; st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a7f53bc3134419cb7b7f00bbd39430b42" title="Returns the next token that would be returned by the Next method.">Peek</a>() &lt;&lt; <span class="stringliteral">&quot;\&quot;&quot;</span>;
<a name="l00662"></a>00662         <span class="keywordflow">throw</span> std::runtime_error(err_ss.str());
<a name="l00663"></a>00663       }
<a name="l00664"></a>00664       <span class="comment">// Read comma, if present.</span>
<a name="l00665"></a>00665       <span class="keywordflow">if</span> (st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a7f53bc3134419cb7b7f00bbd39430b42" title="Returns the next token that would be returned by the Next method.">Peek</a>() == <span class="stringliteral">&quot;,&quot;</span>) {
<a name="l00666"></a>00666         st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a8fad418b62ae370295fe324229e5d43e" title="Returns the next token in the token stream.">Next</a>();
<a name="l00667"></a>00667       }
<a name="l00668"></a>00668     }
<a name="l00669"></a>00669 
<a name="l00670"></a>00670     <span class="comment">// Read the close parenthesis token for this factory type specification.</span>
<a name="l00671"></a>00671     <span class="keywordflow">if</span> (st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a7f53bc3134419cb7b7f00bbd39430b42" title="Returns the next token that would be returned by the Next method.">Peek</a>() != <span class="stringliteral">&quot;)&quot;</span>) {
<a name="l00672"></a>00672       ostringstream err_ss;
<a name="l00673"></a>00673       err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classreranker_1_1_factory.html#a497687eed621332ca0b9883acc60ce82" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00674"></a>00674              &lt;&lt; <span class="stringliteral">&quot;error: expected &#39;)&#39; at stream position &quot;</span>
<a name="l00675"></a>00675              &lt;&lt; st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a2f79a9d009fac16c76c9bcf653fb88cc" title="Returns the next token&rsquo;s start position, or the byte position of the underlying byte stream if there ...">PeekTokenStart</a>() &lt;&lt; <span class="stringliteral">&quot; but found \&quot;&quot;</span> &lt;&lt; st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a7f53bc3134419cb7b7f00bbd39430b42" title="Returns the next token that would be returned by the Next method.">Peek</a>() &lt;&lt; <span class="stringliteral">&quot;\&quot;&quot;</span>;
<a name="l00676"></a>00676       <span class="keywordflow">throw</span> std::runtime_error(err_ss.str());
<a name="l00677"></a>00677     }
<a name="l00678"></a>00678     st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a8fad418b62ae370295fe324229e5d43e" title="Returns the next token in the token stream.">Next</a>();
<a name="l00679"></a>00679 
<a name="l00680"></a>00680     <span class="comment">// Run through all member initializers: if any are required but haven&#39;t</span>
<a name="l00681"></a>00681     <span class="comment">// been invoked, it is an error.</span>
<a name="l00682"></a>00682     <span class="keywordflow">for</span> (<span class="keyword">typename</span> <a class="code" href="classreranker_1_1_initializers.html#a81b3d2bebb775df4c0b83366c833f035" title="Forward the const_iterator typedef of the internal data structure, to make code compact and readable...">Initializers::const_iterator</a> init_it = initializers.begin();
<a name="l00683"></a>00683          init_it != initializers.end();
<a name="l00684"></a>00684          ++init_it) {
<a name="l00685"></a>00685       <a class="code" href="classreranker_1_1_member_initializer.html" title="An interface for initializers of members of a Factory-constructible object.">MemberInitializer</a> *member_initializer = init_it-&gt;second;
<a name="l00686"></a>00686       <span class="keywordflow">if</span> (member_initializer-&gt;<a class="code" href="classreranker_1_1_member_initializer.html#a628dcf5f10c9fb79f27254fcfd21cfe3">Required</a>() &amp;&amp;
<a name="l00687"></a>00687           member_initializer-&gt;<a class="code" href="classreranker_1_1_member_initializer.html#aae102105102356914b4a92d7d92b0a56" title="Returns the number of times this member initializer&rsquo;s Init method has been invoked.">Initialized</a>() == 0) {
<a name="l00688"></a>00688         ostringstream err_ss;
<a name="l00689"></a>00689         err_ss &lt;&lt; <span class="stringliteral">&quot;Factory&lt;&quot;</span> &lt;&lt; <a class="code" href="classreranker_1_1_factory.html#a497687eed621332ca0b9883acc60ce82" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() &lt;&lt; <span class="stringliteral">&quot;&gt;: &quot;</span>
<a name="l00690"></a>00690                &lt;&lt; <span class="stringliteral">&quot;error: initialization for member with name \&quot;&quot;</span>
<a name="l00691"></a>00691                &lt;&lt; init_it-&gt;first &lt;&lt; <span class="stringliteral">&quot;\&quot; required but not found (current &quot;</span>
<a name="l00692"></a>00692                &lt;&lt; <span class="stringliteral">&quot;stream position: &quot;</span> &lt;&lt; st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a6afa23fd8d78598209e49b8723683b79" title="Returns the number of bytes read from the underlying byte stream just after scanning the most recent ...">tellg</a>() &lt;&lt; <span class="stringliteral">&quot;)&quot;</span>;
<a name="l00693"></a>00693         <span class="keywordflow">throw</span> std::runtime_error(err_ss.str());
<a name="l00694"></a>00694       }
<a name="l00695"></a>00695     }
<a name="l00696"></a>00696 
<a name="l00697"></a>00697     <span class="keywordtype">size_t</span> end = st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#a6afa23fd8d78598209e49b8723683b79" title="Returns the number of bytes read from the underlying byte stream just after scanning the most recent ...">tellg</a>();
<a name="l00698"></a>00698     <span class="comment">// Invoke new instance&#39;s Init method.</span>
<a name="l00699"></a>00699     <span class="keywordtype">string</span> stream_str = st.<a class="code" href="classreranker_1_1_stream_tokenizer.html#af4765dcb4f25bb60a13f879536d68288" title="Returns the entire sequence of characters read so far by this stream tokenizer as a newly constructed...">str</a>();
<a name="l00700"></a>00700     <span class="comment">//cerr &lt;&lt; &quot;Full stream string is: \&quot;&quot; &lt;&lt; stream_str &lt;&lt; &quot;\&quot;&quot; &lt;&lt; endl;</span>
<a name="l00701"></a>00701     <span class="keywordtype">string</span> init_str = stream_str.substr(start, end - start);
<a name="l00702"></a>00702     <span class="comment">//cerr &lt;&lt; &quot;Init string is: \&quot;&quot; &lt;&lt; init_str &lt;&lt; &quot;\&quot;&quot; &lt;&lt; endl;</span>
<a name="l00703"></a>00703     instance-&gt;Init(env_ptr.get(), init_str);
<a name="l00704"></a>00704 
<a name="l00705"></a>00705     <span class="keywordflow">return</span> instance;
<a name="l00706"></a>00706   }
<a name="l00707"></a>00707 
<a name="l00708"></a><a class="code" href="classreranker_1_1_factory.html#a6f4d2f54c4530cb070b90baa4877640a">00708</a>   shared_ptr&lt;T&gt; <a class="code" href="classreranker_1_1_factory.html#a68117013334b03c94fc525e62080311f" title="Dynamically creates an object, whose type and initialization are contained in a specification string...">CreateOrDie</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;spec, <span class="keyword">const</span> <span class="keywordtype">string</span> err_msg,
<a name="l00709"></a>00709                             <a class="code" href="classreranker_1_1_environment.html" title="An interface for an environment in which variables of various types are mapped to their values...">Environment</a> *env = NULL) {
<a name="l00710"></a>00710     <a class="code" href="classreranker_1_1_stream_tokenizer.html" title="A simple class for tokenizing a stream of tokens for the formally specified language used to construc...">StreamTokenizer</a> st(spec);
<a name="l00711"></a>00711     <span class="keywordflow">return</span> <a class="code" href="classreranker_1_1_factory.html#a68117013334b03c94fc525e62080311f" title="Dynamically creates an object, whose type and initialization are contained in a specification string...">CreateOrDie</a>(st, env);
<a name="l00712"></a>00712   }
<a name="l00713"></a>00713 
<a name="l00714"></a>00714 
<a name="l00716"></a><a class="code" href="classreranker_1_1_factory.html#a497687eed621332ca0b9883acc60ce82">00716</a>   <span class="keyword">virtual</span> <span class="keyword">const</span> <span class="keywordtype">string</span> <a class="code" href="classreranker_1_1_factory.html#a497687eed621332ca0b9883acc60ce82" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> base_name_; }
<a name="l00717"></a>00717 
<a name="l00725"></a><a class="code" href="classreranker_1_1_factory.html#a5d150fb6e621783b7d71e8dac8f145cd">00725</a>   <span class="keyword">static</span> <span class="keywordtype">bool</span> <a class="code" href="classreranker_1_1_factory.html#a5d150fb6e621783b7d71e8dac8f145cd" title="Returns whether the specified type has been registered with this factory (where registration happens ...">IsRegistered</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;type) {
<a name="l00726"></a>00726     <span class="keywordflow">return</span> initialized_ &amp;&amp; cons_table_-&gt;find(type) != cons_table_-&gt;end();
<a name="l00727"></a>00727   }
<a name="l00728"></a>00728 
<a name="l00730"></a><a class="code" href="classreranker_1_1_factory.html#a1805fa630698b85e498cb707f81cb554">00730</a>   <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_factory.html#a1805fa630698b85e498cb707f81cb554">CollectRegistered</a>(unordered_set&lt;string&gt; &amp;registered)<span class="keyword"> const </span>{
<a name="l00731"></a>00731     <span class="keywordflow">if</span> (initialized_) {
<a name="l00732"></a>00732       <span class="keywordflow">for</span> (<span class="keyword">typename</span> unordered_map&lt;<span class="keywordtype">string</span>, <span class="keyword">const</span> <a class="code" href="classreranker_1_1_constructor.html" title="An interface with a single virtual method that constructs a concrete instance of the abstract type T...">Constructor&lt;T&gt;</a> *&gt;::iterator it =
<a name="l00733"></a>00733                cons_table_-&gt;begin();
<a name="l00734"></a>00734            it != cons_table_-&gt;end();
<a name="l00735"></a>00735            ++it) {
<a name="l00736"></a>00736         registered.insert(it-&gt;first);
<a name="l00737"></a>00737       }
<a name="l00738"></a>00738     }
<a name="l00739"></a>00739   }
<a name="l00740"></a>00740 
<a name="l00741"></a><a class="code" href="classreranker_1_1_factory.html#ad4254b84185e3c479811ee9c68cb28c7">00741</a>   <span class="keyword">virtual</span> <a class="code" href="classreranker_1_1_var_map_base.html" title="A base class for a mapping from variables of a specific type to their values.">VarMapBase</a> *<a class="code" href="classreranker_1_1_factory.html#ad4254b84185e3c479811ee9c68cb28c7">CreateVarMap</a>(<a class="code" href="classreranker_1_1_environment.html" title="An interface for an environment in which variables of various types are mapped to their values...">Environment</a> *env)<span class="keyword"> const </span>{
<a name="l00742"></a>00742     <span class="keywordtype">bool</span> is_primitive = <span class="keyword">false</span>;
<a name="l00743"></a>00743     <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classreranker_1_1_var_map.html" title="A container to hold the mapping between named variables of a specific type and their values...">VarMap&lt;shared_ptr&lt;T&gt;</a> &gt;(<a class="code" href="classreranker_1_1_factory.html#a497687eed621332ca0b9883acc60ce82" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>(), env, is_primitive);
<a name="l00744"></a>00744   }
<a name="l00745"></a>00745 
<a name="l00746"></a><a class="code" href="classreranker_1_1_factory.html#add485d5ad36809087244990d01542336">00746</a>   <span class="keyword">virtual</span> <a class="code" href="classreranker_1_1_var_map_base.html" title="A base class for a mapping from variables of a specific type to their values.">VarMapBase</a> *<a class="code" href="classreranker_1_1_factory.html#add485d5ad36809087244990d01542336">CreateVectorVarMap</a>(<a class="code" href="classreranker_1_1_environment.html" title="An interface for an environment in which variables of various types are mapped to their values...">Environment</a> *env)<span class="keyword"> const </span>{
<a name="l00747"></a>00747     <span class="keywordtype">string</span> name = <a class="code" href="classreranker_1_1_factory.html#a497687eed621332ca0b9883acc60ce82" title="Returns the name of the base type of objects constructed by this factory.">BaseName</a>() + <span class="stringliteral">&quot;[]&quot;</span>;
<a name="l00748"></a>00748     <span class="keywordtype">bool</span> is_primitive = <span class="keyword">false</span>;
<a name="l00749"></a>00749     <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="classreranker_1_1_var_map.html" title="A container to hold the mapping between named variables of a specific type and their values...">VarMap&lt;vector&lt;shared_ptr&lt;T&gt;</a> &gt; &gt;(name, env, is_primitive);
<a name="l00750"></a>00750   }
<a name="l00751"></a>00751 
<a name="l00757"></a><a class="code" href="classreranker_1_1_factory.html#a91816c7ee7c55db9b20036a602d63511">00757</a>   <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classreranker_1_1_constructor.html" title="An interface with a single virtual method that constructs a concrete instance of the abstract type T...">Constructor&lt;T&gt;</a> *<a class="code" href="classreranker_1_1_factory.html#a91816c7ee7c55db9b20036a602d63511" title="The method used by the REGISTER_NAMED macro to ensure that subclasses add themselves to the factory...">Register</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &amp;type,
<a name="l00758"></a>00758                                         <span class="keyword">const</span> <a class="code" href="classreranker_1_1_constructor.html" title="An interface with a single virtual method that constructs a concrete instance of the abstract type T...">Constructor&lt;T&gt;</a> *p) {
<a name="l00759"></a>00759     <span class="keywordflow">if</span> (!initialized_) {
<a name="l00760"></a>00760       cons_table_ = <span class="keyword">new</span> unordered_map&lt;string, const Constructor&lt;T&gt; *&gt;();
<a name="l00761"></a>00761       initialized_ = 1;
<a name="l00762"></a>00762       <a class="code" href="classreranker_1_1_factory_container.html#acc7effa13e093d95c7866d95ecda9324" title="Adds the specified factory to this container of factories.">FactoryContainer::Add</a>(<span class="keyword">new</span> <a class="code" href="classreranker_1_1_factory.html" title="Factory for dynamically created instance of the specified type.">Factory&lt;T&gt;</a>());
<a name="l00763"></a>00763     }
<a name="l00764"></a>00764     (*cons_table_)[type] = p;
<a name="l00765"></a>00765     <span class="keywordflow">return</span> p;
<a name="l00766"></a>00766   }
<a name="l00767"></a>00767 
<a name="l00773"></a><a class="code" href="classreranker_1_1_factory.html#a892eeb8c39013c68c4082c2247d1cbf3">00773</a>   <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classreranker_1_1_factory.html#a892eeb8c39013c68c4082c2247d1cbf3" title="Clears all static data associated with this class.">ClearStatic</a>() {
<a name="l00774"></a>00774     <span class="keywordflow">if</span> (initialized_) {
<a name="l00775"></a>00775       <span class="keywordflow">for</span> (<span class="keyword">typename</span> unordered_map&lt;<span class="keywordtype">string</span>, <span class="keyword">const</span> <a class="code" href="classreranker_1_1_constructor.html" title="An interface with a single virtual method that constructs a concrete instance of the abstract type T...">Constructor&lt;T&gt;</a> *&gt;::iterator it =
<a name="l00776"></a>00776                cons_table_-&gt;begin();
<a name="l00777"></a>00777            it != cons_table_-&gt;end();
<a name="l00778"></a>00778            ++it) {
<a name="l00779"></a>00779         <span class="keyword">delete</span> it-&gt;second;
<a name="l00780"></a>00780       }
<a name="l00781"></a>00781       <span class="keyword">delete</span> cons_table_;
<a name="l00782"></a>00782       initialized_ = 0;
<a name="l00783"></a>00783     }
<a name="l00784"></a>00784   }
<a name="l00785"></a>00785  <span class="keyword">private</span>:
<a name="l00786"></a>00786   <span class="comment">// data members</span>
<a name="l00788"></a>00788 <span class="comment"></span>  <span class="keyword">static</span> <span class="keywordtype">int</span> initialized_;
<a name="l00790"></a>00790   <span class="keyword">static</span> unordered_map&lt;string, const Constructor&lt;T&gt; *&gt; *cons_table_;
<a name="l00791"></a>00791   <span class="keyword">static</span> <span class="keyword">const</span> <span class="keywordtype">char</span> *base_name_;
<a name="l00792"></a>00792 };
<a name="l00793"></a>00793 
<a name="l00800"></a><a class="code" href="factory_8_h.html#a0440aa6c8d7080a9daa203766dae388d">00800</a> <span class="preprocessor">#define DEFINE_CONS_CLASS(TYPE,NAME,BASE) \</span>
<a name="l00801"></a>00801 <span class="preprocessor">  class NAME ## Constructor : public Constructor&lt;BASE&gt; { \</span>
<a name="l00802"></a>00802 <span class="preprocessor">   public: virtual BASE *NewInstance() const { return new TYPE(); } };</span>
<a name="l00803"></a>00803 <span class="preprocessor"></span>
<a name="l00814"></a><a class="code" href="factory_8_h.html#a0b09e4aaef613d7556c07875c7d5a029">00814</a> <span class="preprocessor">#define REGISTER_NAMED(TYPE,NAME,BASE)  \</span>
<a name="l00815"></a>00815 <span class="preprocessor">  DEFINE_CONS_CLASS(TYPE,NAME,BASE) \</span>
<a name="l00816"></a>00816 <span class="preprocessor">  const Constructor&lt;BASE&gt; *NAME ## _my_protoype = \</span>
<a name="l00817"></a>00817 <span class="preprocessor">      Factory&lt;BASE&gt;::Register(string(#NAME), new NAME ## Constructor());</span>
<a name="l00818"></a>00818 <span class="preprocessor"></span>
<a name="l00821"></a><a class="code" href="factory_8_h.html#a01b208854b036ee1381a9289186ff3c2">00821</a> <span class="preprocessor">#define IMPLEMENT_FACTORY(BASE) \</span>
<a name="l00822"></a>00822 <span class="preprocessor">  template&lt;&gt; int Factory&lt;BASE&gt;::initialized_ = 0; \</span>
<a name="l00823"></a>00823 <span class="preprocessor">  template&lt;&gt; unordered_map&lt;string, const Constructor&lt;BASE&gt; *&gt; * \</span>
<a name="l00824"></a>00824 <span class="preprocessor">    Factory&lt;BASE&gt;::cons_table_ = 0; \</span>
<a name="l00825"></a>00825 <span class="preprocessor">  template&lt;&gt; const char *Factory&lt;BASE&gt;::base_name_ = #BASE;</span>
<a name="l00826"></a>00826 <span class="preprocessor"></span>
<a name="l00827"></a>00827 }  <span class="comment">// namespace reranker</span>
<a name="l00828"></a>00828 
<a name="l00829"></a>00829 <span class="preprocessor">#endif</span>
</pre></div></div><!-- contents -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Tue Jan 7 2014 15:24:57 for Reranker Framework (ReFr) by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.6.1
</small></address>

</body>
</html>
